package com.sso.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author liuzhiqiang
 */
@RestController
public class IndexController {

    @GetMapping("/")
    public String index(HttpServletResponse response, String token, Boolean loginState) throws IOException {
        if (loginState == null) {
            // 重定向至认证页面
            response.sendRedirect("http://127.0.0.1:5003/index.html?original=http://127.0.0.1:5001");
            return null;
        } else if (!loginState) {
            // 未登录
            response.sendRedirect("http://127.0.0.1:5001/login.html");
            return null;
        } else {
            System.out.println("token&&"+token);
            return "index";
        }

    }
}
